<?php

namespace App\Console\Commands;

use App\Models\Bus\Bus;
use App\Models\Bus\BusIsCheck;
use Illuminate\Console\Command;

class busCheckData extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'bus:check';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Command description';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        $date = [
            '2019-12-01',
            '2020-01-01',
            '2020-02-01',
            '2020-03-01',
            '2020-04-01',
        ];
        $bus = Bus::all()->pluck('id')->toArray();
        foreach ($date as $kk => $vv) {
            foreach ($bus as $k => $id) {
                $b = Bus::query()->find($id);
                $data = [
                    'is_check' => 1,
                    'month'    => $vv,
                ];
                $isCheck = new BusIsCheck($data);
                $b->isCheck()->save($isCheck);
            }
        }
    }
}
